package com.yq.core.test;

import java.util.*;

/**
 * 文件名：
 * 创建人：lvjx
 * 创建日期: 2017-07-11 10:20
 * 描  述：
 * 版本号：1.0
 */

public class A11X5 {

    public int getNumber() {
        Random r=new Random();
        return r.nextInt(6)+1;
    }

    public static void main(String[] args) {

        Map<Integer, Integer> map = new HashMap(){{
            put(1, 0);
            put(2, 0);
            put(3, 0);
            put(4, 0);
            put(5, 0);
            put(6, 0);
            put(7, 0);
            put(8, 0);
            put(9, 0);
            put(10, 0);
            put(11, 0);
        }};

        A11X5 a11 = new A11X5();

//        Map<Integer, Integer> mapf = new HashMap();
//        int cishu = 0;
//
//        while (true) {
//            int n = mapf.get(a11.gei5(map));
//            if(n!=null) {
//
//            }
//        }

        //for(int i=0; i<5; i++) {
            //if(mapf.get(a11.gei5(map))!=null) {

            //}
            System.out.println(a11.gei5(map));
        //}

      /*  for(int i=0; i<1000000; i++) {
            int num = a11.getNumber();
            map.put(num, map.get(num)+1);
        }

        Map<Integer, Integer> paixu = new HashMap<Integer, Integer>();

        for (Map.Entry<Integer, Integer> entry: map.entrySet()) {
            //System.out.println("排序之前:"+entry.getKey()+" 值"+entry.getValue());
            paixu.put(entry.getValue(), entry.getKey());

        }

        SortedMap<Integer,Integer> sort=new TreeMap<Integer,Integer>(paixu);
        Set<Map.Entry<Integer,Integer>> entry1=sort.entrySet();
        Iterator<Map.Entry<Integer,Integer>> it=entry1.iterator();
        while(it.hasNext()) {
            Map.Entry<Integer,Integer> entry=it.next();
            System.out.println("排序之后:"+entry.getKey()+" 值"+entry.getValue());
        }*/

    }

    public Integer gei5(Map<Integer, Integer> map ) {

        int number = 0;

        //A11X5 a11 = new A11X5();
        for(int i=0; i<1000000; i++) {
            int num = getNumber();
            map.put(num, map.get(num)+1);
        }

        Map<Integer, Integer> paixu = new HashMap<Integer, Integer>();

        for (Map.Entry<Integer, Integer> entry: map.entrySet()) {
            //System.out.println("排序之前:"+entry.getKey()+" 值"+entry.getValue());
            paixu.put(entry.getValue(), entry.getKey());

        }

        SortedMap<Integer,Integer> sort=new TreeMap<Integer,Integer>(paixu);
        Set<Map.Entry<Integer,Integer>> entry1=sort.entrySet();
        Iterator<Map.Entry<Integer,Integer>> it=entry1.iterator();
        while(it.hasNext()) {
            Map.Entry<Integer,Integer> entry=it.next();
            System.out.println("排序之后:"+entry.getKey()+" 值"+entry.getValue());
            number = entry.getValue();
        }

        return number;
    }
}
